package com.shark.open.vo;

import lombok.Data;

import java.util.Collection;

@Data
public class PageVo {
    private long totalCnt;
    private long totalPage;
    private long pageIndex;
    private long pageSize;
    private Collection list;

    public static PageVo of(long totalCnt, long pageIndex, long pageSize, Collection list) {
        PageVo pageVo = new PageVo();
        pageVo.setTotalCnt(totalCnt);
        pageVo.setPageIndex(pageIndex);
        pageVo.setPageSize(pageSize);
        pageVo.setList(list);
        long pageCnt = totalCnt / pageSize;
        if (totalCnt % pageSize > 0) pageCnt = pageCnt + 1;
        pageVo.setTotalPage(pageCnt);
        return pageVo;
    }
}
